<?php

use app\common\enum\DeliveryType as DeliveryTypeEnum;

// 订单详情
$detail = isset($detail) ? $detail : null;

?>
<div class="row-content am-cf"> 
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget__order-detail widget-body am-margin-bottom-lg">

                    <div class="widget-head am-cf">
                        <div class="widget-title am-fl">订单信息</div>
                    </div>
                    <div class="am-scrollable-horizontal">
                        <table class="regional-table am-table am-table-bordered am-table-centered am-text-nowrap am-margin-bottom-xs">
                            <tbody>
                                <tr>

                                    <th>订单号</th>
                                    <?php foreach ($detail as $order): ?>
                                        <?php if($order['pay_status'] == 2 && $order['order_status'] == 20):?>
                                            <th>交易号</th>
                                        <?php endif; ?>
                                    <?php  endforeach;?>
                                    <th>门票总金额</th>

                                    <th>订单状态</th>
                                </tr>
                                <?php foreach ($detail as $order): ?>
                                    <tr>

                                        <td><?= $order['order_no'] ?></td>
                                        <?php if($order['pay_status'] == 2 && $order['order_status'] == 20):?>
                                            <td>
                                                <?= $order['transaction_no'] ?>
                                            </td>
                                        <?php endif; ?>
                                        <td>￥<?= $order['total_price'] ?></td>

                                        <td class="am-text-middle">
                                            <p>付款状态：
                                                <span class="am-badge <?= $order['pay_status'] == 1 ? '' : 'am-badge-success' ?> ">
                                                    <?= $order['pay_status'] == 1 ? '未付款' : '已付款' ?>
                                                </span>
                                            </p>
                                            <p>订单状态：
                                                <span class="am-badge am-badge-warning">
                                                    <?php
                                                    if( $order['order_status'] == 10 )  {
                                                        echo '已下单 待支付';
                                                    }else if( $order['order_status'] == 11 ){
                                                        echo '已下单后取消';
                                                    } else if( $order['order_status'] == 20 ){
                                                        echo '已支付 待核销';
                                                    } else if( $order['order_status'] == 21 ){
                                                        echo '已支付后取消';
                                                    } else if( $order['order_status'] == 80 ){

                                                        echo '已完成';
                                                    }
                                                    ?>
                                                </span>
                                            </p>
                                        </td>
                                    </tr>
                                <?php endforeach;?>
                            </tbody>
                        </table>
                    </div>


                    <div class="widget-head am-cf">
                        <div class="widget-title am-fl">商品信息</div>
                    </div>
                    <div class="am-scrollable-horizontal">
                        <table class="regional-table am-table am-table-bordered am-table-centered am-text-nowrap am-margin-bottom-xs">
                            <tbody>
                            <tr>
                                <th>票名</th>
                                <th>购买数量</th>
                                <th>小计</th>
                                <th>单价</th>
                                <th>商品描述</th>
                            </tr>
                            <?php foreach ($list as $order): ?>
                                <?php foreach ($order['OrderTicket'] as $data): ?>
                                    <tr>
                                        <td><?= $data['name']?>(<?= $data['type'] == 1 ? '单票' : '套票'?>)</td>
                                        <td>×<?= $data['num'] ?>(张)</td>
                                        <td>￥<?php echo (int)$data['price'] * (int)$data['num']; ?></td>
                                        <td><?= $data['price']?></td>
                                        <td><?= $data['content']?></td>
                                    </tr>
                                <?php endforeach;?>
                            <?php endforeach;?>
                            </tbody>
                        </table>
                    </div>

                    <?php foreach ($list as $order): ?>

                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">付款信息</div>
                            </div>
                            <div class="am-scrollable-horizontal">
                                <table class="regional-table am-table am-table-bordered am-table-centered
                                    am-text-nowrap am-margin-bottom-xs">
                                    <tbody>
                                        <tr>

                                            <th>总金额</th>
                                            <th>应付金额</th>
                                            <th>支付方式</th>
                                            <th>付款状态</th>
                                            <th>付款时间</th>
                                        </tr>
                                        <tr>

                                            <td>
                                                <?php $name = 0; ?>
                                                <?php foreach ($order['OrderTicket'] as $data): ?>
                                                <?php $name += (int)$data['price'] * (int)$data['num']; ?>
                                                <?php endforeach;?>
                                                ￥<?php echo $name; ?>
                                            </td>
                                            <td>
                                                <?php $name = 0; ?>
                                                <?php foreach ($order['OrderTicket'] as $data): ?>
                                                    <?php $name += (int)$data['price'] * (int)$data['num']; ?>
                                                <?php endforeach;?>
                                                ￥<?php echo $name; ?>
                                            </td>
                                            <td>微信</td>
                                            <td>
                                                <span class="am-badge <?= $order[0]['pay_status'] == 1 ? '' : 'am-badge-success' ?> ">
                                                        <?= $order[0]['pay_status'] == 1 ? '未付款' : '已付款' ?>
                                                </span>
                                            </td>
                                            <td>
                                                <?= $order[0]['pay_time'] ? date('Y-m-d H:i:s', $order[0]['pay_time']) : '--' ?>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>

                    <?php endforeach;?>

                    <div class="widget-head am-cf">
                        <div class="widget-title am-fl">用户信息</div>
                    </div>
                    <div class="am-scrollable-horizontal">
                        <table class="regional-table am-table am-table-bordered am-table-centered am-text-nowrap am-margin-bottom-xs">
                            <tbody>
                            <tr>
                                <th>微信头像</th>
                                <th>微信昵称</th>
                                <th>性别</th>

                                <th>地区</th>
                                <th>累积消费金额</th>

                            </tr>
                            <?php foreach ($detail as $order): ?>
                                <tr>
                                    <td>
                                        <img src="<?= $order['avatarUrl'] ?>" alt="">
                                    </td>
                                    <td>
                                        <?= $order['nickName'] ?>
                                        <p class="am-link-muted">(用户id：<?= $order['user_id'] ?>)</p>
                                    </td>
                                    <td><?= $order['gender'] == 1 ? '男' : '女' ?></td>

                                    <td><?= $order['province']?>/<?= $order['city']?></td>
                                    <td><?= $order['expend_money']?></td>

                                </tr>
                            <?php endforeach;?>
                            </tbody>
                        </table>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
